import request from '@/utils/request'

// 查询拼购商品列表
export function listGroupGoods(query) {
  return request({
    url: '/market/groupGoods/list',
    method: 'get',
    params: query
  })
}

// 查询拼购商品详细
export function getGroupGoods(id) {
  return request({
    url: '/market/groupGoods/' + id,
    method: 'get'
  })
}
// 查询拼购商品列表
export function getGroupGoodsByGroupId(groupId) {
  return request({
    url: '/market/groupGoods/getGroupGoodsByGroupId/' + groupId,
    method: 'get'
  })
}

// 新增拼购商品
export function addGroupGoods(data) {
  return request({
    url: '/market/groupGoods',
    method: 'post',
    data: data
  })
}
// 修改拼购商品
export function updateGroupGoods(data) {
  return request({
    url: '/market/groupGoods',
    method: 'put',
    data: data
  })
}

// 删除拼购商品
export function delGroupGoods(id) {
  return request({
    url: '/market/groupGoods/' + id,
    method: 'delete'
  })
}

// 上移
export function moveUpGoods(data) {
  return request({
    url: '/market/groupGoods/moveUpGoods',
    method: 'post',
    data: data
  })
}

// 下移
export function moveDownGoods(data) {
  return request({
    url: '/market/groupGoods/moveDownGoods',
    method: 'post',
    data: data
  })
}

// 状态修改
export function changeGroupGoodsStatus(id, isShow) {
  const data = {
    id,
    isShow
  }
  console.log(data)
  return request({
    url: '/market/groupGoods/changeStatus',
    method: 'post',
    data: data
  })
}
